using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class PhysFeesCategoryMap : EntityTypeConfiguration<PhysFeesCategory>
    {
        public PhysFeesCategoryMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("PhysFeesCategory");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.PlanId).HasColumnName("PlanId");
            this.Property(t => t.CategoryId).HasColumnName("CategoryId");
            this.Property(t => t.Percentage).HasColumnName("Percentage");

            // Relationships
            this.HasRequired(t => t.PhysFeesPlan)
                .WithMany(t => t.PhysFeesCategories)
                .HasForeignKey(d => d.PlanId);

        }
    }
}
